import axios from 'axios'

const service = axios.create({
    // http基地址
  baseURL: process.env.VUE_APP_BASE_API,
    // 跨域请求是否提供凭据信息(cookie、HTTP认证及客户端SSL证明等)
  withCredentials: process.env.AXIOS_WITH_CREDENTIALS,
    // 超时
  timeout: 100000
})

// 发送请求拦截
service.interceptors.request.use(
  config => {
    return config
  },
  error => {
    return Promise.reject(error)
  }
)

// 接收请求结果拦截
service.interceptors.response.use(
  response => {
    return response.data
  },
  error => {
    return Promise.reject(error)
  }
)

export default service
